package com.hdoit.ares.web.cbase;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.hdoit.ares.logical.cust.service.ICustomerService;
import com.tennetcn.component.intceptor.IWechatPayIntceptor;

@Component
public class WechatPayIntceptor implements IWechatPayIntceptor{
	
	
	
	private ICustomerService customerService;
	
	public ICustomerService getCustomerService() {
		return customerService;
	}
	
	@Resource
	public void setCustomerService(ICustomerService customerService) {
		this.customerService = customerService;
	}

	@Override
	public void pay(WxPayOrderNotifyResult payOrderNotifyResult, Object object) {
		/*if("success".equals(payOrderNotifyResult.getReturnCode().toLowerCase())){
			WechatOrder wechatOrder=(WechatOrder)object;
			//发送支付消息通知
			sendPayMessage(wechatOrder);
			
		}*/
	}
	
	/*
	private void sendPayMessage(WechatOrder wechatOrder){
		Customer joinCustomer = customerService.queryModelByOpenId(wechatOrder.getOpenId());
		Customer refreeCustomer = customerService.queryModelByUserIdentity(joinCustomer.getRefereeIdentity());
		String isHas = "";
		if(refreeCustomer.getUserIdentity()>1000){
			String category = "joinByrefreeCustomer";
			RedEnvelopeRecord redEnvelopeRecord = redEnvelopeRecordService.queryModelByCategory(joinCustomer.getId(), refreeCustomer.getId(), category);
			if(redEnvelopeRecord==null){
				isHas = "no";
			}else{
				isHas = "yes";
			}
		}
		
		WechatTemplateManager.sendOrderPaySuccess(wechatOrder.getOpenId(), wechatOrder.getTotalFee(), wechatOrder.getName(),isHas);		
	}
	*/

	

	
}
